package com.jeecms.cms.manager.assist.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeecms.cms.dao.assist.CmsOrderExtDao;
import com.jeecms.cms.entity.assist.CmsOrder;
import com.jeecms.cms.entity.assist.CmsOrderExt;
import com.jeecms.cms.manager.assist.CmsOrderExtMng;
import com.jeecms.common.hibernate3.Updater;

@Service
@Transactional
public class CmsOrderExtMngImpl implements CmsOrderExtMng {
	public CmsOrderExt save(CmsOrderExt ext, CmsOrder cmsOrder) {
		cmsOrder.setExt(ext);
		ext.setOrder(cmsOrder);
		ext.init();
		dao.save(ext);
		return ext;
	}

	public CmsOrderExt update(CmsOrderExt ext) {
		Updater<CmsOrderExt> updater = new Updater<CmsOrderExt>(ext);
		CmsOrderExt entity = dao.updateByUpdater(updater);
		entity.blankToNull();
		return entity;
	}

	private CmsOrderExtDao dao;

	@Autowired
	public void setDao(CmsOrderExtDao dao) {
		this.dao = dao;
	}
}